﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using DTOFrameworks;
using PhysicalDataProvider;
using FooFun.DataElements.Dtos;
using FooFun.Web.Utils;

namespace FAQFrameworks
{
    public class SiteUrls
    {
        // todo: 测试
        public static string ConcludelQuestion(Guid topicId, Guid replyId)
        {
            return "Manager/ConcludelQuestion.ashx?TopicId="
                 + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.TopicId)
                 + "&ReplyId=" + SiteUrlsProvider.GetGuidUrl(replyId);
        }
        public static string ConcludelQuestion(Guid topicId,
            IDataElement replyId)
        {
            Guid guid = DataProviderUtil.GetGuid(replyId.Value);

            return "Manager/ConcludelQuestion.ashx?TopicId="
                + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.TopicId)
                + "&ReplyId=" + SiteUrlsProvider.GetGuidUrl(guid);
        }

        public static string UserProfile(Guid userId)
        {
            return "~/User/Default.aspx?AccountId=" + SiteUrlsProvider.GetGuidUrl(userId);
        }

        public static string UserProfile(IDataElement userId)
        {
            Guid guid = DataProviderUtil.GetGuid(userId.Value);

            return "~/User/Default.aspx?AccountId=" + SiteUrlsProvider.GetGuidUrl(guid);
        }
        public static string AddReply
        {
            get
            {
                string str = "Manager/AddReply.ashx?TopicId="
                     + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.TopicId);

                return str;
            }
        }

        public static string AskQuestion
        {
            get
            {
                string str = "~/AskQuestion.aspx";

                str += "?ForumId="
                    + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.ForumId);

                return str;
            }
        }

        public static string Login
        {
            get
            {
                string returnUrl
                    = FAQContext.Current.ReturnUrl;

                if (returnUrl != null)
                {
                    return "~/Login.aspx?ReturnUrl="
                        + HttpUtility.UrlEncode(returnUrl);
                }
                else
                {
                    string rawUrl = HttpContext.Current.Request.RawUrl;
                    return "~/Login.aspx?ReturnUrl="
                        + HttpUtility.UrlEncode(rawUrl);
                }
            }
        }

        public static string Logout
        {
            get
            {
                string rawUrl = HttpContext.Current.Request.RawUrl;
                return "~/Logout.aspx?ReturnUrl="
                    + HttpUtility.UrlEncode(rawUrl);
            }
        }

        public static string Home
        {
            get
            {
                return "~/Default.aspx";
            }
        }

        public static string TopicView(Guid topicId)
        {
            return "~/TopicView.aspx?TopicId="
                + SiteUrlsProvider.GetGuidUrl(topicId);
        }

        public static string TopicView(IDataElement topicId)
        {
            Guid guid = DataProviderUtil.GetGuid(topicId.Value);

            return "~/TopicView.aspx?TopicId="
                + SiteUrlsProvider.GetGuidUrl(guid);
        }

        public static string Register
        {
            get
            {
                return "~/Register.aspx";
            }
        }

        public static string ForumView(Guid forumId)
        {
            return "~/ForumView.aspx?ForumId="
                + SiteUrlsProvider.GetGuidUrl(forumId);
        }

        public static string ForumView(IDataElement forumId)
        {
            Guid guid = DataProviderUtil.GetGuid(forumId.Value);

            return "~/ForumView.aspx?ForumId="
                + SiteUrlsProvider.GetGuidUrl(guid);
        }

        public static string AskedTopic
        {
            get
            {
                return "~/ForumView.aspx?ForumId="
                    + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.ForumId)
                    + "&Tab=UnSealed";
            }
        }

        public static string SealedTopic
        {
            get
            {
                return "~/ForumView.aspx?ForumId="
                    + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.ForumId)
                    + "&Tab=SealedTopic";
            }
        }

        public static string UserTopic
        {
            get
            {
                return "~/User/Default.aspx?AccountId="
                    + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.AccountId);
            }
        }

        public static string UserReply
        {
            get
            {
                return "~/User/Default.aspx?AccountId="
                    + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.AccountId)
                    + "&Tab=Answer";
            }
        }

        public static string UserPassword
        {
            get
            {
                return "~/User/Default.aspx?AccountId="
                    + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.AccountId)
                    + "&Tab=Pwd";
            }
        }

        public static string LastTopic
        {
            get
            {
                return "~/ForumView.aspx?ForumId="
                + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.ForumId)
                + "&Tab=LastTopic";
            }
        }

        public static string LastReply
        {
            get
            {
                return "~/ForumView.aspx?ForumId="
                + SiteUrlsProvider.GetGuidUrl(FAQContext.Current.ForumId)
                + "&Tab=LastReply";
            }
        }

        public static string AdminForm(IDataElement forumId)
        {
            Guid guid = DataProviderUtil.GetGuid(forumId.Value);

            return "~/Admin/Default.aspx?ForumId="
                + SiteUrlsProvider.GetGuidUrl(guid);
        }

        public static string GetGuidUrl(IDataElement id)
        {
            Guid guid = DataProviderUtil.GetGuid(id.Value);

            string url = SiteUrlsProvider.GetGuidUrl(guid);

            return url;

        }
    }
}
